package com.powernode.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.powernode.domain.VisitLog;
import com.powernode.dto.VisitLogDto;
import com.powernode.mapper.VisitLogMapper;
import com.powernode.service.VisitLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class VisitLogServiceImpl implements VisitLogService{

    @Resource
    private VisitLogMapper visitLogMapper;

    @Override
    public int insert(VisitLog record) {
        return visitLogMapper.insert(record);
    }

    @Override
    public int insertSelective(VisitLog record) {
        return visitLogMapper.insertSelective(record);
    }

    /**
     * 根据客户id查询当前客户的拜访记录
     * @param visitLogDto
     * @return
     */
    @Override
    public PageInfo<VisitLog> listVisitLogByCustomerId(VisitLogDto visitLogDto) {
        Page<VisitLog> page=PageHelper.startPage(visitLogDto.getPage(),visitLogDto.getLimit());
        List<VisitLog> visitLogList=this.visitLogMapper.queryVisitLogByCustomerById(visitLogDto.getCustomerId());
        return page.toPageInfo();
    }

}
